package pailaidai.hc.com.mysvgdemo.rxjava;


import android.util.Log;

import rx.Observable;
import rx.Observer;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2018/5/24.
 */

public class RxJavaDemo {
    Observer<String> observer = new Observer<String>() {
        @Override
        public void onCompleted() {

        }

        @Override
        public void onError(Throwable e) {

        }

        @Override
        public void onNext(String s) {

        }
    };
    Observable observable = Observable.create(new Observable.OnSubscribe<String>() {
        @Override
        public void call(Subscriber<? super String> subscriber) {
            subscriber.onNext("Hello");
            subscriber.onNext("Wrold");
            subscriber.onCompleted();
        }
    });

    Subscriber subscriber = new Subscriber() {
        @Override
        public void onCompleted() {

        }

        @Override
        public void onError(Throwable e) {

        }

        @Override
        public void onNext(Object o) {

        }
    };

    private void rxJavaTest3() {
    Observable.just("Hello","World")
            .subscribeOn(Schedulers.newThread())//指定subscribe()发生在新的线程
            .observeOn(AndroidSchedulers.mainThread())//指定Subscriber的回调发生在主线程
            .subscribe(new Action1<String>() {
                @Override
                public void call(String s) {
                    Log.i("ssssssssss",s);
                }
            });
    }





}
